/*
 *  This file is part of Spidex.
 *  
 *  Spidex is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Spidex is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with Spidex.  If not, see <http://www.gnu.org/licenses/>.
 */

package spidex.importer;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author xatrix
 */
public class TableSettings {
    private boolean multipleNames = false;
    Map<Integer,ColumnType> column2Type = new HashMap<Integer,ColumnType>();
    Map<ColumnType,Integer> type2Column = new HashMap<ColumnType,Integer>();
    int firstRow;
    int lastRow;

    public TableSettings() {
    }

    public Map<Integer, ColumnType> getColumn2Type() {
        return column2Type;
    }

    public void setColumn2Type(Map<Integer, ColumnType> column2Type) {
        this.column2Type = column2Type;
    }

    public int getFirstRow() {
        return firstRow;
    }

    public void setFirstRow(int firstRow) {
        this.firstRow = firstRow;
    }

    public int getLastRow() {
        return lastRow;
    }

    public void setLastRow(int lastRow) {
        this.lastRow = lastRow;
    }

    public boolean isMultipleNames() {
        return multipleNames;
    }

    public void setMultipleNames(boolean multipleNames) {
        this.multipleNames = multipleNames;
    }

    public Map<ColumnType, Integer> getType2Column() {
        return type2Column;
    }

    public void setType2Column(Map<ColumnType, Integer> type2Column) {
        this.type2Column = type2Column;
    }
    
    @SuppressWarnings("empty-statement")
    public void addEntry(Integer column, ColumnType type) {
        System.out.println(column+"|"+type.toString());
        if( this.column2Type.containsKey(column) && column >= 0) {
            throw new IllegalArgumentException("Column is already setted");
        };
        this.column2Type.put(column, type);
        if(column >= 0) {
            this.type2Column.put(type, column);
        }
    }
    
    public String toString() {
        return this.column2Type.toString()+"\n"+this.type2Column.toString();
    }

    
}
